package com.workmanager.service;

import com.workmanager.bean.StudentBean;
import com.workmanager.bean.TeacherBean;
import com.workmanager.mapper.regMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Li on 2016/8/31.
 */
@Service("regService")
public class regService {
    @Resource(name="regmapper")
    private regMapper regmapper;
    public boolean checkNumber(String num){
     int stu= regmapper.checkStudentPhone(num);
     int tea= regmapper.checkTeacherPhone(num);
        if(stu==0&&tea==0){
            return true;
        }else
            return false;
    }
    public boolean doteacherreg(TeacherBean teacherBean){
        Map<String,String> para=new HashMap<String, String>();
        para.put("teachername",teacherBean.getTeacher_name());
        para.put("teacherphone",teacherBean.getTeacher_phone());
        para.put("teacherpassword",teacherBean.getTeacher_password());
        System.out.println("te"+para.get("teacherphone"));
        int re = regmapper.doteacherreg(para);
        return re>0;
    }
    public boolean dostudentreg(StudentBean studentBean){
        Map<String,String> para=new HashMap<String, String>();
        para.put("studentname",studentBean.getStudent_name());
        para.put("studentphone",studentBean.getStudent_phone());
        para.put("studentpassword",studentBean.getStudent_password());
        System.out.println("stu"+para.get("studentphone"));
        int re = regmapper.dostudentreg(para);
        return re>0;
    }

    public regMapper getRegmapper() {
        return regmapper;
    }

    public void setRegmapper(regMapper regmapper) {
        this.regmapper = regmapper;
    }

}

